<template>
  <view class="boxs" :style="'background-image:url(' + latestData.images.homePage + ')'">
    <view class="btns" @click="ceshi"></view>
    <!-- <view class="upload-btn" @click="goToUpload"></view> -->
    <view class="youxia" @click="handleYouxiaClick"></view>
  </view>
</template>

<script>
import request from '@/utils/request.js';
import mpShare from '@/uni_modules/uv-ui-tools/libs/mixin/mpShare.js';
export default {
  mixins: [mpShare],
  components: {}, //注册插件
  data() {
    return {
      latestData: {},
      clickCount: 0
    }
  },
  created() {
    this.getdata()
  },
  onReady() {
  },
  methods: {
    getdata() {
      const _this = this;
      request({
        url: '/api.php',
        method: 'GET',
        header: {
          'Content-Type': 'application/json'
        }
      }).then(res => {
        if (res.code === 0 && res.data) {
          // 直接使用返回的数据对象
          this.latestData = res.data;

        }
      }).catch(err => {
        console.error('加载数据失败:', err);
      }).finally(() => {
        _this.uploading = false;
      });

    },
    ceshi() {
      uni.navigateTo({
        url: '/pages/ceshi/ceshi'
      });
    },

    goToUpload() {
      uni.navigateTo({
        url: '/pages/upload/upload'
      });
    },
    handleYouxiaClick() {
      // 增加点击计数
      this.clickCount++;

      // 当连续点击达到10次时跳转到上传页面
      if (this.clickCount >= 10) {
        uni.navigateTo({
          url: '/pages/upload/upload'
        });
        // 重置计数器
        this.clickCount = 0;
      }
    }
  }
}
</script>

<style scoped>
.youxia {
  position: fixed;
  width: 100upx;
  height: 100upx;
  bottom: 0;
  right: 0;
}

.btns {
  width: 90%;
  height: 35vh;
  position: fixed;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
}

.upload-btn {
  width: 80%;
  height: 15vh;
  position: fixed;
  left: 50%;
  bottom: 15%;
  transform: translate(-50%, 0);
}

.boxs {
  background: #011032;
  width: 100%;
  height: 100vh;
  background-size: cover;
  background-position: center;
}
</style>